﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>ViewEmpList</title>
    <link href="<%= this.Url.Content("~/content/Global.css") %>" rel="Stylesheet" type="text/css" />
    <link href="<%= this.Url.Content("~/content/Site.css") %>" rel="Stylesheet" type="text/css" />

    <script type="text/javascript" language="javascript" src="<%=this.Url.Content("~/content/scripts/jquery-1.4.2.js") %>"></script>

</head>
<body style="width: 675px;">
    <div>
        <div id="dv_emplist_frame" class="dv_emplist_frame">
        </div>
    </div>
</body>

<script type="text/javascript" language="javascript">
    // 全局根路径
    var dircache = '<%=this.Url.Content("~/caches/") %>';
    var rid = '<%=ViewData["rid"] %>';
    var sid = '<%=ViewData["sid"] %>';
    $(function() {
        loadEmpInfo();
        $("a[id^='ash']").click(function() {
            var id = this.id.substr(3);
            $("#divsh" + id).toggle();
            if ($("#divsh" + id + ":hidden").length > 0) {
                $(this).html("查看人员");
            } else {
                $(this).html("隐藏人员");
            }
        });
    });
    function loadEmpInfo() {
        //取路线基本信息
        var ri = $.ajax({
            url: dircache + 'base_info/' + rid + '.js?rnd=' + Math.random(),
            async: false,
            dataType: "json"
        }).responseText;
        try {
            ri = eval("(" + ri + ")");
        } catch (ex) { ri = null; }
        //取路线及站点的人员数
        var sinums = $.ajax({
            url: dircache + 'gps_nums/' + rid + '.js?rnd=' + Math.random(),
            async: false,
            dataType: "json"
        }).responseText;
        try {
            sinums = eval("(" + sinums + ")");
        } catch (ex) { sinums = null; }
        var sinum = 0;
        var j = 0;
        var i = 0;
        var emphtml = '';
        if (ri != null && sinums != null) {
            //取路线的名称及人员
            emphtml += '<div>路线 ' + ri.rname + ' 平均刷卡人数:' + (sinums.rcnt / 2).toFixed(0) + '人&nbsp;&nbsp;<a id="ash' + ri.rid + '" href=#>查看人员</a></div>';
            emphtml += '<div id="divsh' + ri.rid + '" style="display:none;border:solid 1px #d5e8f3;color:gray;">' + getEmpList(ri.rid) + '</div>';
            emphtml += '<div style="padding-left:10px;">';
            for (j = 0; j < ri.ss.length; j++) {
                for (i = 0; i < sinums.s.length; i++) {
                    if (sinums.s[i].sid == ri.ss[j].sid) {
                        sinum = sinums.s[i].scnt;
                        break;
                    }
                }
                emphtml += '<div>' + ri.ss[j].sname + ':' + parseFloat(sinum).toFixed(1) + '人&nbsp;&nbsp;<a id="ash' + ri.ss[j].sid + '" href=#>查看人员</a></div>';
                emphtml += '<div id="divsh' + ri.ss[j].sid + '" style="display:none;border:solid 1px #d5e8f3;color:gray;">' + getEmpList(ri.ss[j].sid) + '</div>';
            }
        }
        emphtml += '</div>';
        var emplist = '<div style="color:red;">注：此列表中是近几天每天都乘坐本班车的员工，与平均人数并不一定相等。</div>' +
                '<div style="font-size:14px;margin-top:10px;">' +
                emphtml + '</div>';
        $("#dv_emplist_frame").append(emplist);
    }
    function getEmpList(id) {
        var liststr = '';
        var silist = $.ajax({
            url: dircache + 'gps_emplist/' + id + '.js?rnd=' + Math.random(),
            async: false,
            dataType: "json"
        }).responseText;
        try {
            silist = eval("(" + silist + ")");
        } catch (ex) { silist = null; }
        if (silist != null && silist.emps != null) {
            liststr = silist.emps.toString();
        }
        return liststr == '' ? '暂无' : liststr;
    }
</script>

</html>
